package com.har.modules.web.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.har.common.utils.PageUtils;
import com.har.common.utils.Query;
import com.har.modules.web.dao.FinanceProducDao;
import com.har.modules.web.entity.FinanceProducEntity;
import com.har.modules.web.service.FinanceProducService;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("financeProducService")
public class FinanceProducServiceImpl extends ServiceImpl<FinanceProducDao, FinanceProducEntity> implements FinanceProducService {


    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        EntityWrapper<FinanceProducEntity> ew=new EntityWrapper<>();
        if(params.get("productName") != null  && params.get("productName").toString().length() != 0){
            ew.like("product_name","%"+params.get("productName")+"%");
        }
        if(params.get("type") != null  && params.get("type").toString().length() != 0){
            ew.eq("type",params.get("type"));
        }
        ew.eq("product_type",5).orderBy("update_time DESC");
        Page<FinanceProducEntity> page = this.selectPage(
                new Query<FinanceProducEntity>(params).getPage(), ew);

        return new PageUtils(page);
    }


    @Override
    public PageUtils queryAllPage(Map<String, Object> params) {
        EntityWrapper<FinanceProducEntity> ew=new EntityWrapper<>();
        if(null!=params.get("type")&&params.get("type").toString().length()!=0){
            ew.eq("type",params.get("type"));
        }
        if(null!=params.get("productType")&&params.get("productType").toString().length()!=0){
            ew.eq("product_type",params.get("productType"));
        }
        Page<FinanceProducEntity> page = this.selectPage(
                new Query<FinanceProducEntity>(params).getPage(),ew);
        return new PageUtils(page);
    }

}
